package com.jason.unpluggedsuperstar.ui;

import android.content.Context;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.app.ListFragment;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.LinearLayout;
import android.widget.ListView;

import com.jason.unpluggedsuperstar.R;
import com.jason.unpluggedsuperstar.utils.VideoUtils;

public class BeAStar extends Fragment{
	
	private Button mRecordButton = null;
	private Context mContext = null;
	private Fragment mFragment = null;
	private BeAStarVideoList mBeAStarVideoList = null;
	
	public View onCreateView(LayoutInflater inflater, ViewGroup container,
			Bundle savedInstanceState) {
		
		mFragment = this;
		mContext = this.getActivity().getApplicationContext();
		
		if (container == null) {
            // We have different layouts, and in one of them this
            // fragment's containing frame doesn't exist.  The fragment
            // may still be created from its saved state, but there is
            // no reason to try to create its view hierarchy because it
            // won't be displayed.  Note this is not needed -- we could
            // just run the code below, where we would create and return
            // the view hierarchy; it would just never be used.
            return null;
        }
		
		LinearLayout ll = (LinearLayout)inflater.inflate(R.layout.be_a_star, container, false);
		
		mRecordButton = (Button) ll.findViewById(R.id.be_a_star_start_record);
		mRecordButton.setOnClickListener(new OnClickListener(){

			@Override
			public void onClick(View v) {
				VideoUtils mVideoUtils = new VideoUtils(mFragment.getActivity());
				mVideoUtils.startRecord();
			}
			
		});
		
		//Get Child Fragment
		mBeAStarVideoList = (BeAStarVideoList) this.getActivity().getSupportFragmentManager().findFragmentById(R.id.be_a_star_video_list);
		
		return ll;
	}
	
	public void reloadVideoList(){
		mBeAStarVideoList.reloadVideoList();
	}
}
